﻿using ELab.Exceptions;

namespace ELab.Communication.Messages.ControllerMessages
{
    public static class ControlMessageFactory
    {
        public const int MessageTypeIdGeneralResponseMessage = 100;
        public const int MessageTypeIdGetApplicationListMessage = 1;
        public const int MessageTypeIdGetApplicationListResponseMessage = 2;
        public const int MessageTypeIdClientApplicationRefreshEventMessage = 3;
        public const int MessageTypeIdAddNewApplicationMessage = 4;
        public const int MessageTypeIdRemoveApplicationMessage = 5;
        public const int MessageTypeIdRemoveApplicationResponseMessage = 6;
        public const int MessageTypeIdClientApplicationRemovedEventMessage = 7;
        public const int MessageTypeIdGetServerGraphMessage = 8;
        public const int MessageTypeIdGetServerGraphResponseMessage = 9;
        public const int MessageTypeIdUpdateServerGraphMessage = 10;
        public const int MessageTypeIdOperationResultMessage = 11;
        public const int MessageTypeIdGetApplicationWebServicesMessage = 12;
        public const int MessageTypeIdGetApplicationWebServicesResponseMessage = 13;
        public const int MessageTypeIdUpdateApplicationWebServicesMessage = 14;
        public const int MessageTypeIdGetUsersMessage = 15;
        public const int MessageTypeIdGetUsersResponseMessage = 16;
        public const int MessageTypeIdAddNewUserMessage = 17;
        public const int MessageTypeIdRemoveUserMessage = 18;
        public const int MessageTypeIdAddNewSurveyMessage = 19;
        public const int MessageTypeIdRemoveSurveyMessage = 20;
        public const int MessageTypeIdCheckAuthenticationMessage = 21;
        public const int MessageTypeIdCheckAuthenticationResponseMessage = 22;
        public const int MessageTypeIdAddNewQuestionMessage = 23;
        public const int MessageTypeIdGetQuestionListMessage = 24;
        public const int MessageTypeIdGetQuestionListResponseMessage = 25;
        public const int MessageTypeIdGetSurveysMessage = 26;
        public const int MessageTypeIdGetSurveysResponseMessage = 27;
        public const int MessageTypeIdUpdateUserMessage = 28;

        public static ControlMessage CreateMessageByTypeId(int messageTypeId)
        {
            switch (messageTypeId)
            {
                case MessageTypeIdGetUsersMessage:
                    return new GetUsersMessage();
                case MessageTypeIdGetUsersResponseMessage:
                    return new GetUsersResponseMessage();
                case MessageTypeIdAddNewUserMessage:
                    return new AddNewUsersMessage();
                case MessageTypeIdRemoveUserMessage:
                    return new RemoveUsersMessage();
                case MessageTypeIdAddNewSurveyMessage:
                    return new AddNewSurveyMessage();
                case MessageTypeIdRemoveSurveyMessage:
                    return new RemoveSurveyMessage();
                case MessageTypeIdGeneralResponseMessage:
                    return new GeneralResponseMessage();
                case MessageTypeIdGetApplicationListMessage:
                    return new GetApplicationListMessage();
                case MessageTypeIdGetApplicationListResponseMessage:
                    return new GetApplicationListResponseMessage();
                case MessageTypeIdClientApplicationRefreshEventMessage:
                    return new ClientApplicationRefreshEventMessage();
                case MessageTypeIdAddNewApplicationMessage:
                    return new AddNewApplicationMessage();
                case MessageTypeIdRemoveApplicationMessage:
                    return new RemoveApplicationMessage();
                case MessageTypeIdRemoveApplicationResponseMessage:
                    return new RemoveApplicationResponseMessage();
                case MessageTypeIdClientApplicationRemovedEventMessage:
                    return new ClientApplicationRemovedEventMessage();
                case MessageTypeIdGetServerGraphMessage:
                    return new GetServerGraphMessage();
                case MessageTypeIdGetServerGraphResponseMessage:
                    return new GetServerGraphResponseMessage();
                case MessageTypeIdUpdateServerGraphMessage:
                    return new UpdateServerGraphMessage();
                case MessageTypeIdOperationResultMessage:
                    return new OperationResultMessage();
                case MessageTypeIdGetApplicationWebServicesMessage:
                    return new GetApplicationWebServicesMessage();
                case MessageTypeIdGetApplicationWebServicesResponseMessage:
                    return new GetApplicationWebServicesResponseMessage();
                case MessageTypeIdUpdateApplicationWebServicesMessage:
                    return new UpdateApplicationWebServicesMessage();
                case MessageTypeIdCheckAuthenticationMessage:
                    return new CheckAuthenticationMessage();
                case MessageTypeIdCheckAuthenticationResponseMessage:
                    return new CheckAuthenticationResponseMessage();
                case MessageTypeIdAddNewQuestionMessage:
                    return new AddNewQuestionMessage();
                case MessageTypeIdGetQuestionListMessage:
                    return new GetQuestionListMessage();
                case MessageTypeIdGetQuestionListResponseMessage:
                    return new GetQuestionListResponseMessage();
                case MessageTypeIdGetSurveysMessage:
                    return new GetSurveysMessage();
                case MessageTypeIdGetSurveysResponseMessage:
                    return new GetSurveysResponseMessage();
                case MessageTypeIdUpdateUserMessage:
                    return new UpdateUserMessage();
                default:
                    throw new ELabException("Undefined ControlMessage MessageTypeId: " + messageTypeId);
            }
        }
    }
}
